package com.controller;


import com.entity.ThreeLink;
import com.service.ThreeLinkService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/threelink")
public class ThreeLinkController {

    @Resource
    private ThreeLinkService threeLinkService;


    @GetMapping("/show")
    String show(ModelMap modelMap){

        modelMap.addAttribute("threeLinks",threeLinkService.findAll());
        return "/buyer/order";
    }

    @PostMapping("/findCityByPid/{id}")
    @ResponseBody
    public List<ThreeLink> findCityByPid(@PathVariable("id") Integer pid){
        return threeLinkService.findAllCityByPid(pid);
    }

    @PostMapping("/findAreaByCid/{id}")
    @ResponseBody
    public List<ThreeLink> findAreaByCid(@PathVariable("id") Integer cid){
        return threeLinkService.findAllAreaByCid(cid);
    }

}
